package com.ruoyi.psi.sale.salereturn.domain;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;

/**
 * 销售订单退货表
 * psi_sale_return
 * 修改：lsy 2021.7.17
 */
public class SaleReturn extends BaseEntity {

    /**
     * 销售订单退货编号
     */
    @NotNull(message = "销售订单退货编号不能为空")
    @ApiModelProperty(value = "销售订单退货编号", required = true)
    private String saleReturnId;
    /**
     * 销售订单出库编号
     */
    @NotNull(message = "销售订单出库编号不能为空")
    @ApiModelProperty(value = "销售订单出库编号", required = true)
    private String saleDeliveryId;
    /**
     * 员工编号
     */
    @ApiModelProperty(value = "员工编号")
    private String staffId;

    /**
     * 员工名称
     */
    @ApiModelProperty(value = "员工名称")
    private String staffName;
    /**
     * 客户编号
     */
    @ApiModelProperty("客户编号")
    private String customerInfoId;
    /**
     * 客户名称
     */
    @ApiModelProperty("客户名称")
    private String customerInfoName;
    /**
    /**
     * 仓库编号
     */
    @NotNull(message = "仓库编号不能为空")
    @ApiModelProperty(value = "仓库编号", required = true)
    private String warehouseId;
    /**
     * 仓库名称
     */
    @ApiModelProperty("仓库名称")
    @Excel(name = "仓库名称")
    private String warehouseName;
    /**
     * 销售退货数量
     */
    @ApiModelProperty("销售退货数量")
    private double saleReturnNumberTotal;
    /**
     * 销售退货金额
     */
    @ApiModelProperty("销售退货金额")
    private double saleReturnPriceTotal;
    /**
     * 退货时间
     */
    @ApiModelProperty("退货时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp returnTime;
    /**
     * 备注
     */
    @ApiModelProperty("备注")
    private String remark;
    /**
     * 是否审批
     */
    @ApiModelProperty("是否审批")
    private String approvalFlag;
    /**
     * 销售订单退货详细
     */
    private List<SaleReturnList>saleReturnLists;

    public List<SaleReturnList> getSaleReturnLists() {
        return saleReturnLists;
    }

    public void setSaleReturnLists(List<SaleReturnList> saleReturnLists) {
        BigDecimal srnt = new BigDecimal("0");//saleReturnNumberTotal,销售退货数量
        BigDecimal srpt = new BigDecimal("0");//saleReturnPriceTotal,销售退货金额
        for (SaleReturnList s:saleReturnLists) {
            srnt = srnt.add(BigDecimal.valueOf(s.getSaleReturnNumber()));
            srpt = srpt.add(BigDecimal.valueOf(s.getSaleReturnPrice()));
        }
        setSaleReturnNumberTotal(srnt.doubleValue());
        setSaleReturnPriceTotal(srpt.doubleValue());
        this.saleReturnLists = saleReturnLists;
    }

    public double getSaleReturnNumberTotal() {
        return saleReturnNumberTotal;
    }

    public void setSaleReturnNumberTotal(double saleReturnNumberTotal) {
        this.saleReturnNumberTotal = saleReturnNumberTotal;
    }

    public double getSaleReturnPriceTotal() {
        return saleReturnPriceTotal;
    }

    public void setSaleReturnPriceTotal(double saleReturnPriceTotal) {
        this.saleReturnPriceTotal = saleReturnPriceTotal;
    }

    public String getStaffId() {
        return staffId;
    }

    public void setStaffId(String staffId) {
        this.staffId = staffId;
    }

    public String getStaffName() {
        return staffName;
    }

    public void setStaffName(String staffName) {
        this.staffName = staffName;
    }

    @Override
    public String toString() {
        return "SaleReturn{" +
                "saleReturnId='" + saleReturnId + '\'' +
                ", saleDeliveryId='" + saleDeliveryId + '\'' +
                ", staffId='" + staffId + '\'' +
                ", staffName='" + staffName + '\'' +
                ", customerInfoId='" + customerInfoId + '\'' +
                ", customerInfoName='" + customerInfoName + '\'' +
                ", warehouseId='" + warehouseId + '\'' +
                ", warehouseName='" + warehouseName + '\'' +
                ", saleReturnNumberTotal=" + saleReturnNumberTotal +
                ", saleReturnPriceTotal=" + saleReturnPriceTotal +
                ", returnTime=" + returnTime +
                ", remark='" + remark + '\'' +
                ", approvalFlag='" + approvalFlag + '\'' +
                ", saleReturnLists=" + saleReturnLists +
                '}';
    }

    public String getApprovalFlag() {
        return approvalFlag;
    }

    public void setApprovalFlag(String approvalFlag) {
        this.approvalFlag = approvalFlag;
    }

    public String getSaleReturnId() {
        return saleReturnId;
    }

    public void setSaleReturnId(String saleReturnId) {
        this.saleReturnId = saleReturnId;
    }

    public String getSaleDeliveryId() {
        return saleDeliveryId;
    }

    public void setSaleDeliveryId(String saleDeliveryId) {
        this.saleDeliveryId = saleDeliveryId;
    }

    public String getCustomerInfoId() {
        return customerInfoId;
    }

    public void setCustomerInfoId(String customerInfoId) {
        this.customerInfoId = customerInfoId;
    }

    public String getCustomerInfoName() {
        return customerInfoName;
    }

    public void setCustomerInfoName(String customerInfoName) {
        this.customerInfoName = customerInfoName;
    }

    public String getWarehouseId() {
        return warehouseId;
    }

    public void setWarehouseId(String warehouseId) {
        this.warehouseId = warehouseId;
    }

    public String getWarehouseName() {
        return warehouseName;
    }

    public void setWarehouseName(String warehouseName) {
        this.warehouseName = warehouseName;
    }

    public Timestamp getReturnTime() {
        return returnTime;
    }

    public void setReturnTime(Timestamp returnTime) {
        this.returnTime = returnTime;
    }

    @Override
    public String getRemark() {
        return remark;
    }

    @Override
    public void setRemark(String remark) {
        this.remark = remark;
    }
}
